package com.nook.config;

import cn.hutool.core.lang.ClassScanner;
import com.mybatisflex.core.mybatis.FlexConfiguration;
import com.mybatisflex.solon.ConfigurationCustomizer;
import org.apache.ibatis.annotations.Mapper;
import org.noear.solon.annotation.Configuration;

import java.util.Set;


@Configuration
public class CustomConfigurationCustomizer implements ConfigurationCustomizer {

    @Override
    public void customize(FlexConfiguration configuration) {
        Set<Class<?>> classes = ClassScanner.scanPackageByAnnotation("com.nook", Mapper.class);
        if (classes == null || classes.isEmpty()) {
            return;
        }
        classes.forEach(configuration::addMapper);
    }
}